from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1225651798.9779999
_template_filename='webappex/error_500.html'
_template_uri='error_500.html'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding='utf-8'
_exports = ['dicttable_items']


# SOURCE LINE 1

import pprint
def prettify(x):
    try: 
        out = pprint.pformat(x)
    except Exception, e: 
        out = '[could not display: <' + e.__class__.__name__ + \
              ': '+str(e)+'>]'
    return out


def render_body(context,exception_type,exception_value,frames,handler,out,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(exception_type=exception_type,pageargs=pageargs,handler=handler,frames=frames,exception_value=exception_value,out=out)
        items = context.get('items', UNDEFINED)
        len = context.get('len', UNDEFINED)
        str = context.get('str', UNDEFINED)
        def dicttable_items(items,kls='req',id=None):
            return render_dicttable_items(context.locals_(__M_locals),items,kls,id)
        __M_writer = context.writer()
        # SOURCE LINE 10
        __M_writer(u'')
        # SOURCE LINE 11
        __M_writer(u'')
        # SOURCE LINE 25
        __M_writer(u'')
        # SOURCE LINE 26

        def dicttable(d, kls='req', id=None):
            items = d and d.items() or []
            items.sort()
            dicttable_items(items, kls, id)
            return ""
        
        
        __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin()[__M_key]) for __M_key in ['dicttable'] if __M_key in __M_locals_builtin()]))
        # SOURCE LINE 32
        __M_writer(u'')
        # SOURCE LINE 33
        __M_writer(u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html lang="en">\n<head>\n  <meta http-equiv="content-type" content="text/html; charset=utf-8" />\n  <meta name="robots" content="NONE,NOARCHIVE" />\n  <title>')
        # SOURCE LINE 38
        __M_writer(filters.html_escape(unicode(exception_type )))
        __M_writer(u' at ')
        __M_writer(filters.html_escape(unicode(handler.request.path_info )))
        __M_writer(u'</title>\n  <style type="text/css">\n    html * { padding:0; margin:0; }\n    body * { padding:10px 20px; }\n    body * * { padding:0; }\n    body { font:small sans-serif; }\n    body>div { border-bottom:1px solid #ddd; }\n    h1 { font-weight:normal; }\n    h2 { margin-bottom:.8em; }\n    h2 span { font-size:80%; color:#666; font-weight:normal; }\n    h3 { margin:1em 0 .5em 0; }\n    h4 { margin:0 0 .5em 0; font-weight: normal; }\n    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }\n    tbody td, tbody th { vertical-align:top; padding:2px 3px; min-width: 120px; }\n    thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }\n    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }\n    table.vars { margin:5px 0 2px 40px; }\n    table.vars td, table.req td { font-family:monospace; }\n    table td.code { width:100%; }\n    table td.code div { overflow:hidden; }\n    table.source th { color:#666; }\n    table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }\n    ul.traceback { list-style-type:none; }\n    ul.traceback li.frame { margin-bottom:1em; }\n    div.context { margin: 10px 0; }\n    div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }\n    div.context ol li { font-family:monospace; white-space:pre; color:#666; cursor:pointer; }\n    div.context ol.context-line li { color:black; background-color:#ccc; }\n    div.context ol.context-line li span { float: right; }\n    div.commands { margin-left: 40px; }\n    div.commands a { color:black; text-decoration:none; }\n    #summary { background: #ffc; }\n    #summary h2 { font-weight: normal; color: #666; }\n    #explanation { background:#eee; }\n    #template, #template-not-exist { background:#f6f6f6; }\n    #template-not-exist ul { margin: 0 0 0 20px; }\n    #unicode-hint { background:#eee; }\n    #traceback { background:#eee; }\n    #requestinfo { background:#f6f6f6; padding-left:120px; }\n    #summary table { border:none; background:transparent; }\n    #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }\n    #requestinfo h3 { margin-bottom:-1em; }\n    .error { background: #ffc; }\n    .specific { color:#cc3300; font-weight:bold; }\n    h2 span.commands { font-size:.7em;}\n    span.commands a:link {color:#5E5694;}\n    pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; }\n  </style>\n  <script type="text/javascript">\n  //<!--\n    function getElementsByClassName(oElm, strTagName, strClassName){\n        // Written by Jonathan Snook, http://www.snook.ca/jon; \n        // Add-ons by Robert Nyman, http://www.robertnyman.com\n        var arrElements = (strTagName == "*" && document.all)? document.all :\n        oElm.getElementsByTagName(strTagName);\n        var arrReturnElements = new Array();\n        strClassName = strClassName.replace(/\\-/g, "\\\\-");\n        var oRegExp = new RegExp("(^|\\\\s)" + strClassName + "(\\\\s|$$)");\n        var oElement;\n        for(var i=0; i<arrElements.length; i++){\n            oElement = arrElements[i];\n            if(oRegExp.test(oElement.className)){\n                arrReturnElements.push(oElement);\n            }\n        }\n        return (arrReturnElements)\n    }\n    function hideAll(elems) {\n      for (var e = 0; e < elems.length; e++) {\n        elems[e].style.display = \'none\';\n      }\n    }\n    window.onload = function() {\n      hideAll(getElementsByClassName(document, \'table\', \'vars\'));\n      hideAll(getElementsByClassName(document, \'ol\', \'pre-context\'));\n      hideAll(getElementsByClassName(document, \'ol\', \'post-context\'));\n    }\n    function toggle() {\n      for (var i = 0; i < arguments.length; i++) {\n        var e = document.getElementById(arguments[i]);\n        if (e) {\n          e.style.display = e.style.display == \'none\' ? \'block\' : \'none\';\n        }\n      }\n      return false;\n    }\n    function varToggle(link, id) {\n      toggle(\'v\' + id);\n      var s = link.getElementsByTagName(\'span\')[0];\n      var uarr = String.fromCharCode(0x25b6);\n      var darr = String.fromCharCode(0x25bc);\n      s.innerHTML = s.innerHTML == uarr ? darr : uarr;\n      return false;\n    }\n    //-->\n  </script>\n</head>\n<body>\n<div id="summary">\n  <h1>')
        # SOURCE LINE 137
        __M_writer(filters.html_escape(unicode(exception_type )))
        __M_writer(u' at ')
        __M_writer(filters.html_escape(unicode(handler.request.path_info )))
        __M_writer(u'</h1>\n  <pre class="exception_value">')
        # SOURCE LINE 138
        __M_writer(filters.html_escape(unicode(exception_value )))
        __M_writer(u'</pre>\n  <table><tr>\n    <th>Python</th>\n    <td>')
        # SOURCE LINE 141
        __M_writer(filters.html_escape(unicode(frames[0].filename )))
        __M_writer(u' in ')
        __M_writer(filters.html_escape(unicode(frames[0].function )))
        __M_writer(u', line ')
        __M_writer(unicode(frames[0].lineno))
        __M_writer(u'</td>\n  </tr><tr>\n    <th>Web</th>\n    <td>')
        # SOURCE LINE 144
        __M_writer(unicode(handler.request.method))
        __M_writer(u' ')
        __M_writer(filters.html_escape(unicode(handler.request.path_url )))
        __M_writer(u'</td>\n  </tr></table>\n</div>\n<div id="traceback">\n<h2>Traceback <span>(innermost first)</span></h2>\n<ul class="traceback">\n')
        # SOURCE LINE 150
        for frame in frames:
            # SOURCE LINE 151
            __M_writer(u'    <li class="frame">\n    <code>')
            # SOURCE LINE 152
            __M_writer(filters.html_escape(unicode(frame.filename )))
            __M_writer(u'</code> in <code>')
            __M_writer(filters.html_escape(unicode(frame.function )))
            __M_writer(u'</code>\n')
            # SOURCE LINE 153
            if frame.context_line:
                # SOURCE LINE 154
                __M_writer(u'        <div class="context" id="c')
                __M_writer(unicode(frame.id))
                __M_writer(u'">\n')
                # SOURCE LINE 155
                if frame.pre_context:
                    # SOURCE LINE 156
                    __M_writer(u'            <ol start="')
                    __M_writer(unicode(frame.pre_context_lineno))
                    __M_writer(u'" class="pre-context" id="pre')
                    __M_writer(unicode(frame.id))
                    __M_writer(u'">\n')
                    # SOURCE LINE 157
                    for line in frame.pre_context:
                        # SOURCE LINE 158
                        __M_writer(u'                <li onclick="toggle(\'pre')
                        __M_writer(unicode(frame.id))
                        __M_writer(u"', 'post")
                        __M_writer(unicode(frame.id))
                        __M_writer(u'\')">')
                        __M_writer(filters.html_escape(unicode(line )))
                        __M_writer(u'</li>\n')
                    # SOURCE LINE 160
                    __M_writer(u'            </ol>\n')
                # SOURCE LINE 162
                __M_writer(u'            <ol start="')
                __M_writer(unicode(frame.lineno))
                __M_writer(u'" class="context-line"><li onclick="toggle(\'pre')
                __M_writer(unicode(frame.id))
                __M_writer(u"', 'post")
                __M_writer(unicode(frame.id))
                __M_writer(u'\')">')
                __M_writer(filters.html_escape(unicode(frame.context_line )))
                __M_writer(u' <span>...</span></li></ol>\n')
                # SOURCE LINE 163
                if frame.post_context:
                    # SOURCE LINE 164
                    __M_writer(u"            <ol start='")
                    __M_writer(unicode(frame.lineno + 1))
                    __M_writer(u'\' class="post-context" id="post')
                    __M_writer(unicode(frame.id))
                    __M_writer(u'">\n')
                    # SOURCE LINE 165
                    for line in frame.post_context:
                        # SOURCE LINE 166
                        __M_writer(u'                <li onclick="toggle(\'pre')
                        __M_writer(unicode(frame.id))
                        __M_writer(u"', 'post")
                        __M_writer(unicode(frame.id))
                        __M_writer(u'\')">')
                        __M_writer(filters.html_escape(unicode(line )))
                        __M_writer(u'</li>\n')
                    # SOURCE LINE 168
                    __M_writer(u'            </ol>\n')
                # SOURCE LINE 170
                __M_writer(u'      </div>\n')
            # SOURCE LINE 172
            if frame.vars:
                # SOURCE LINE 173
                __M_writer(u'        <div class="commands">\n        <a href=\'#\' onclick="return varToggle(this, \'')
                # SOURCE LINE 174
                __M_writer(unicode(frame.id))
                __M_writer(u'\')"><span>&#x25b6;</span> Local vars</a>\n        </div>\n        ')
                # SOURCE LINE 176
                __M_writer(unicode(dicttable(frame.vars, kls='vars', id=('v' + str(frame.id)))))
                __M_writer(u'\n')
            # SOURCE LINE 178
            __M_writer(u'    </li>\n')
        # SOURCE LINE 180
        __M_writer(u'  </ul>\n</div>\n\n<div id="requestinfo">\n')
        # SOURCE LINE 184
        if len(out)>0 or len(handler.response.headers._headers)>0:
            # SOURCE LINE 185
            __M_writer(u'<h2>Response so far</h2>\n<h3>HEADERS</h3>\n')
            # SOURCE LINE 187
            __M_writer(unicode(dicttable_items(handler.response.headers._headers)))
            __M_writer(u'\n\n<h3>BODY</h3>\n<p class="req" style="padding-bottom: 2em"><code>\n')
            # SOURCE LINE 191
            __M_writer(filters.html_escape(unicode(out )))
            __M_writer(u'\n</code></p>\n')
        # SOURCE LINE 194
        __M_writer(u'<h2>Request information</h2>\n\n<h3 id="get-info">GET</h3>\n')
        # SOURCE LINE 197
        __M_writer(unicode(dicttable(handler.request.GET)))
        __M_writer(u'\n\n<h3 id="post-info">POST</h3>\n')
        # SOURCE LINE 200
        __M_writer(unicode(dicttable(handler.request.POST)))
        __M_writer(u'\n\n<h3 id="cookie-info">COOKIES</h3>\n')
        # SOURCE LINE 203
        __M_writer(unicode(dicttable(handler.request.cookies)))
        __M_writer(u'\n\n<h3 id="meta-info">ENVIRON</h3>\n')
        # SOURCE LINE 206
        __M_writer(unicode(dicttable(handler.request.environ)))
        __M_writer(u'\n</div>\n\n<div id="explanation">\n  <p>\n    You\'re seeing this error because you have <code>debug</code>\n    set to <code>True</code>. Set that to <code>False</code> if you don\'t to see this.\n  </p>\n</div>\n\n</body>\n</html>')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_dicttable_items(context,items,kls='req',id=None):
    context.caller_stack._push_frame()
    try:
        __M_writer = context.writer()
        # SOURCE LINE 12
        __M_writer(u'\n')
        # SOURCE LINE 13
        if items:
            # SOURCE LINE 14
            __M_writer(u'        <table class="')
            __M_writer(unicode(kls))
            __M_writer(u'" ')
            __M_writer(unicode(id and 'id="%s"' % id or ""))
            __M_writer(u'>\n        <thead><tr><th>Variable</th><th>Value</th></tr></thead>\n        <tbody>\n')
            # SOURCE LINE 17
            for  k, v in items:
                # SOURCE LINE 18
                __M_writer(u'        <tr><td>')
                __M_writer(filters.html_escape(unicode(k )))
                __M_writer(u'</td><td class="code"><div>')
                __M_writer(filters.html_escape(unicode(prettify(v) )))
                __M_writer(u'</div></td></tr>\n')
            # SOURCE LINE 20
            __M_writer(u'        </tbody>\n        </table>\n')
            # SOURCE LINE 22
        else:
            # SOURCE LINE 23
            __M_writer(u'        <p>No data.</p>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


